import { createSSRApp } from "vue";
import "uno.css";
import App from "./App.vue";
import uviewPlus from "uview-plus";
import msgInfo from "@/utils/msgInfo.js";
import { createI18n } from "vue-i18n";
import lang from "./lang/index";
import { createPinia } from "pinia";
declare module "vue" {
	interface ComponentCustomProperties {
		t: (key: string) => string;
	}
}
// 全局样式
import "@/static/main.scss";
const localeStore = useUniversalStorage<string>("LOCALE", "zh");
// 导入语言包
const i18n = createI18n({
	legacy: false, // 禁用 Vue 2 兼容模式
	fallbackLocale: "en", // 回退语言
	locale: localeStore.value || uni.getLocale(), // 默认语言
	messages: lang, // 语言包
});

export function createApp() {
	const app = createSSRApp(App);
	const pinia = createPinia();
	app.config.globalProperties.$appVersion = "main";
	app.config.globalProperties.$message = msgInfo;
	app.use(uviewPlus);
	app.use(i18n);
	app.use(pinia);
	return {
		app,
		pinia,
	};
}
